package com.vortex.cloud.sample.easyexcel.kuangshen.poi.write;

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;

import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @author 王林
 * @version 1.0
 * @date 2021-10-15 周五
 * @time 11:18
 * @description
 */
public class WriteExcelTest07BigDataS {

    public static void main(String[] args) throws IOException {

        String PATH = "H:\\fuTaiPorjects\\backend\\hw-clouc-sample-easyExcel";

        // 时间
        Long begin = System.currentTimeMillis();

        //创建一个簿
        Workbook workbook = new SXSSFWorkbook();

        //创建表
        Sheet work = workbook.createSheet();

        //写入数据
        for (int rowNum = 0; rowNum < 100000; rowNum++) {
            Row row = work.createRow(rowNum);
            for (int cellNum = 0; cellNum < 10; cellNum++) {
                Cell cell = row.createCell(cellNum);
                cell.setCellValue(cellNum);

            }
        }
        System.out.println("over!!!");

        FileOutputStream fileOutputStream = new FileOutputStream(PATH + "WriteExcelTest07BigDataS.xlsx");
        workbook.write(fileOutputStream);
        fileOutputStream.close();

        //清楚临时文件 ！
//        ((Workbook) workbook).dispose();
        Long end = System.currentTimeMillis();

        System.out.println((double) (end - begin) / 1000);


    }
}
